#include<iostream>
#include<cstring>
using namespace std;
const int N = 6100, M = N * 2;
int n;
int a[N];
int main()
{
	cin >> n;
	int x = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i == 1)continue;
		x = max(x, a[i]);
	}
	int ans = 0;
	if (x > a[1]) {
		ans = x - a[1] + 1;
	}
	else if (x == a[1])ans = 1;
	cout << ans << endl;
	return 0;
}